using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace SBS_Map_Editor
{
    class Text
    {
        #region Variables
        private float size = 1f;
        private Color color;
        SpriteFont Arial;
        SpriteBatch sprite;
        #endregion

        #region Properties
        public Color Color
        {
            get { return color; }
            set { color = value; }
        }

        public float Size
        {
            get { return size; }
            set { size = value; }
        }
        #endregion

        #region Constructor
        public Text(SpriteBatch _sprite, SpriteFont _Arial)
        {
            Arial = _Arial;
            sprite = _sprite;
        }
        #endregion

        #region Action Functions
        public void DrawText(int x, int y, String s)
        {
            sprite.Begin(SpriteBlendMode.AlphaBlend);
            sprite.DrawString(Arial, s, new Vector2((float)x, (float)y), color, 0f, new Vector2(), size,
                SpriteEffects.None, 1f);
            sprite.End();
        }
        #endregion

        #region Helper Functions
        public bool DrawClickText(int x, int y, string s, int mosX, int mosY, bool mouseClick)
        {
            color = Color.White;
            bool r = false;

            if (mosX > x && mosY > y &&
                mosX < x + Arial.MeasureString(s).X * size &&
                mosY < y + Arial.MeasureString(s).Y * size)
            {
                color = Color.Yellow;
                if (mouseClick)
                    r = true;
            }

            DrawText(x, y, s);

            return r;
        }
        #endregion
    }
}